package com.ghh.dao;

import com.ghh.pojo.Company;
import com.github.pagehelper.Page;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

public interface CompanyDao {

    @Select("select * from t_company")
    List<Company> findAll();

    @Select("<script>select * from t_company <if test=\"value!=null and value!=''\">where address like '%${value}%'</if></script>")
    Page<Company> findPage(@Param("value") String queryString);

    @Insert("insert into t_company values (null,#{address},#{longitude},#{latitude})")
    void addAddress(Company company);

    @Delete("delete from t_company where id=#{id}")
    void delete(Integer id);

    @Select("select id as value,address from t_company")
    List<Map<String,Object>> findAllCompany();
}
